<?php
require_once("../phpGrid_Basic/conf.php");

$dg = new C_DataGrid("SELECT * FROM ordenes_entrega", "ID_ORDEN_ENTREGA", "ordenes_entrega");
 
$dg -> set_caption("Ordenes de Entrega"); 

$dg -> set_col_hidden("ID_ORDEN_ENTREGA");

$dg -> set_col_title("NRO_ORDEN_ENTREGA", "Orden");
$dg -> set_col_title("FECHA_RECEPCION", "Fecha Recepcion");
$dg -> set_col_title("COSTO_TOTAL_OE", "Costo");
$dg -> set_col_title("FECHA_OPERACION", "Fecha Operacion");
$dg -> set_col_title("USUARIO_OPERACION", "Usuario Operacion");

// enable edit
$dg->enable_edit("FORM", "CRUD");

// multiple select
$dg -> set_multiselect(true);

// second grid as detail grid. Notice it is just another regular phpGrid with properites.
$sdg = new C_DataGrid("SELECT * FROM ordenes_trabajo", "ID_ORDEN_TRABAJO", "ordenes_trabajo");


$sdg->enable_edit("FORM", "CRUD");


// second grid as detail grid. Notice it is just another regular phpGrid with properites.
$sdg2 = new C_DataGrid("SELECT * FROM operarios_item", array("ID_ORDEN_TRABAJO","ID_ITEM","ID_OPERARIO"), "operarios_item");

$sdg2->enable_edit("FORM", "CRUD");

// define master detail relationship by passing the detail grid object as the first parameter, then the foriegn key name.
// set query filter
$dg->set_masterdetail($sdg2, 'ID_ORDEN_TRABAJO');
$dg->set_masterdetail($sdg, 'ID_ORDEN_ENTREGA');
// $sdg->set_subgrid($sdg2, 'ID_ORDEN_TRABAJO');
// $dg->set_subgrid($sdg, 'ID_ORDEN_ENTREGA');

$dg->display();
?>